class RolesController < ApplicationController
  include RolesHelper
  include CrudHelper

  before_filter :check_permissions
 #before_filter :check_permissions_write, :only => [:edit,:update]
  skip_before_filter :require_no_authentication

 def check_permissions
   authorize! :manage, :roles
 end

  def create
    @role = Role.new(params[:role])

    respond_to do |format|
      if @role.save
        format.html  { redirect_to(@role,
                                   :notice => 'Role was successfully created.') }
        format.json  { render :json => @role,
                              :status => :created, :location => @role }
      else
        format.html  { render :action => "new" }
        format.json  { render :json => @role.errors,
                              :status => :unprocessable_entity }
      end
    end
  end

  def show
    @role = Role.find(params[:id])

    respond_to do |format|
      format.html
      format.json { render :json => @role }
    end
  end

  def update
    @role = Role.find(params[:id])
  end

  def destroy
    @role = Role.find(params[:id])
    @role.destroy

    respond_to do |format|
      format.html { redirect_to roles_path }
      format.json { head :no_content }
      format.js
    end
  end

  def edit
    @entity = Role.find(params[:id])
  end
end
